<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <p>这是首页</p>
    <button onclick="toNext()">href</button>
    <button onclick="forwardPage()">forward</button>
    <button onclick="goPage()">go</button>
    <!-- <button onclick="history.go('./test1.html')">goURL</button> 不能跳转 -->
    <script>
      console.log(history);
      function toNext() {
        location.href = "./test1.html"; //将跳转的URL写入history
        // location.replace("./test1.html"); //跳转的URL不会写入history 执行的是URL的替换
      }
      console.log(history.length);

      function forwardPage() {
        history.forward();
      }
      function goPage() {
        history.go(1);
      }
    </script>
  </body>
</html>
